<!DOCTYPE html>
<head>
  <meta charset="utf-8">
  <!--[if IE]><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"><![endif]-->
  <title>天量科技管理后台</title>
  <meta name="keywords" content="" />
  <meta name="description" content="" />
  <meta name="viewport" content="width=device-width">
  <link href="favicon.ico" rel="shortcut icon" type="image/x-icon">
  <link rel="stylesheet" href="css/templatemo_main.css">
  <link href="//netdna.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
</head>
<body ng-app="app" ng-controller="index">
<div class="navbar navbar-inverse" role="navigation">
  <div class="navbar-header">
    <div class="logo"><h1>天量科技管理后台</h1></div>
    <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
      <span class="sr-only">Toggle navigation</span>
      <span class="icon-bar"></span>
      <span class="icon-bar"></span>
      <span class="icon-bar"></span>
    </button>
  </div>
</div>
<div class="template-page-wrapper">
  <div class="navbar-collapse collapse templatemo-sidebar">
    <ul class="templatemo-sidebar-menu">
      <li>
        <form class="navbar-form">
          欢迎您:{{user.name || '访客'}}</span>
        </form>
      </li>
      <li ng-repeat="menu in menus" ng-class="menu.menuclass" ng-click="menuclick(menu)">
        <a ng-click="redi(menu.url)" ng-if="menu.items.length==0"><i ng-class="menu.icon"></i>{{menu.label}}</a>
        <a href="#" ng-if="menu.items.length>0">
          <i ng-class="menu.icon"></i> {{menu.label}} <div class="pull-right"><span class="caret"></span></div>
        </a>
        <ul class="templatemo-submenu" ng-if="menu.items.length>0">
          <li ng-repeat="item in menu.items" ng-click="redi(item.url)"><a href="javascript:void(0)">{{item.label}}</a></li>
        </ul>
      </li>
      <li>
        <a href="#" data-toggle="modal" data-target="#confirmModal"><i class="fa fa-sign-out"></i>退出登录</a>
      </li>
    </ul>
  </div><!--/.navbar-collapse -->

  <div class="templatemo-content-wrapper">
    <div class="templatemo-content">
      <ol class="breadcrumb">
        <li><a ng-click="redi('index.html')" href="javascript:void(0)">首页</a></li>
        <li><a ng-click="redi('strategy_test.html')" href="javascript:void(0)">返回</a></li>
        <li ng-repeat="n in data.nameList">
          <a ng-click="open('strategy_test_detail.html?id='+n.id)" href="javascript:void(0)">{{n.id}}:{{n.name}}</a>
        </li>
      </ol>
      <div class="row" ng-if="haserror">
        <div class="alert alert-danger alert-dismissible" role="alert">
          <button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
          <strong>发生异常情况:{{errormessage}}</strong>
        </div>
      </div>

      <div class="templatemo-charts">
        <div class="row">
          <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
            <div class="row templatemo-chart-row">
              <div class="templatemo-chart-box col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <div id="c1" style="width:{{wWidth*0.8}}px;height:{{wHeigth*0.35}}px;"></div>
              </div>
            </div>
          </div>
          <div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
            <div class="row templatemo-chart-row">
              <div class="templatemo-chart-box col-lg-6 col-md-6 col-sm-6 col-xs-6">
                <div id="c2" style="width:{{wWidth*0.4}}px;height:{{wHeigth*0.35}}px;"></div>
              </div>
            </div>
          </div>
          <div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
            <div class="row templatemo-chart-row">
              <div class="templatemo-chart-box col-lg-6 col-md-6 col-sm-6 col-xs-6">
                <div id="c3" style="width:{{wWidth*0.4}}px;height:{{wHeigth*0.35}}px;"></div>
              </div>
            </div>
          </div>
          <div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
            <div class="row templatemo-chart-row">
              <div class="templatemo-chart-box col-lg-6 col-md-6 col-sm-6 col-xs-6">
                <div id="c4" style="width:{{wWidth*0.4}}px;height:{{wHeigth*0.35}}px;"></div>
              </div>
            </div>
          </div>
          <div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
            <div class="row templatemo-chart-row">
              <div class="templatemo-chart-box col-lg-6 col-md-6 col-sm-6 col-xs-6">
                <div id="c5" style="width:{{wWidth*0.4}}px;height:{{wHeigth*0.35}}px;"></div>
              </div>
            </div>
          </div>
          <div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
            <div class="row templatemo-chart-row">
              <div class="templatemo-chart-box col-lg-6 col-md-6 col-sm-6 col-xs-6">
                <div id="c6" style="width:{{wWidth*0.4}}px;height:{{wHeigth*0.35}}px;"></div>
              </div>
            </div>
          </div>
          <div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
            <div class="row templatemo-chart-row">
              <div class="templatemo-chart-box col-lg-6 col-md-6 col-sm-6 col-xs-6">
                <div id="c7" style="width:{{wWidth*0.4}}px;height:{{wHeigth*0.35}}px;"></div>
              </div>
            </div>
          </div>
          <div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
            <div class="row templatemo-chart-row">
              <div class="templatemo-chart-box col-lg-6 col-md-6 col-sm-6 col-xs-6">
                <div id="c8" style="width:{{wWidth*0.4}}px;height:{{wHeigth*0.35}}px;"></div>
              </div>
            </div>
          </div>
          <div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
            <div class="row templatemo-chart-row">
              <div class="templatemo-chart-box col-lg-6 col-md-6 col-sm-6 col-xs-6">
                <div id="c9" style="width:{{wWidth*0.4}}px;height:{{wHeigth*0.35}}px;"></div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>

  <!-- Modal -->
  <div class="modal fade" id="confirmModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
          <h4 class="modal-title" id="myModalLabel">确定退出吗</h4>
        </div>
        <div class="modal-footer">
          <a ng-click="logout()" class="btn btn-primary" data-dismiss="modal">确定</a>
          <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
        </div>
      </div>
    </div>
  </div>

  <footer class="templatemo-footer">
    <div class="templatemo-copyright">
      <p>Copyright &copy; 2018 By <a href="http://skyquant.cn" title="天量科技" target="_blank">天量科技</a></p>
    </div>
  </footer>
</div>
</body>

<script src="//cdn.bootcss.com/jquery/3.1.1/jquery.min.js"></script>
<script src="//cdn.bootcss.com/angular.js/1.5.8/angular.js"></script>
<script src="//cdn.bootcss.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<script src="js/common.js"></script>
<script src="js/templatemo_script.js"></script>
<script src="https://cdn.bootcss.com/echarts/4.1.0-release/echarts.min.js"></script>
<script type="text/javascript">
  'use strict';
  var app = angular.module('app', []);
  function initc1(data){
    var myChart = echarts.init(document.getElementById('c1'));
    var seriesarr = [];
    var legendarr = [];
    data.nameList.forEach(function(val,index,arr){
      legendarr.push(val.id+":"+val.name);
    });
    data.dataList.forEach(function(val,index,arr){
      var series = {
            type: 'line',
            smooth: true,
            name : val.id+":"+val.name,
            showSymbol: false,
            data : val.data,
            lineStyle: {
                normal: {
                    width: 1
                }
            }
      };
      seriesarr.push(series);
    });
    var option = {
      title: {
        text: '策略收益',
        textStyle: {
            fontSize: 12,
        },
        left: 0
      },
      legend: {
          data: legendarr
      },
      tooltip: {
          trigger: 'item',
          axisPointer: {
              type: 'cross'
          },
      },
      xAxis: {
          type: 'category',
          data: data.dates,
          axisLine: { lineStyle: { color: '#8392A5' } },
          splitNumber: 20,
          splitLine: {show: false},
      },
      yAxis: {
          scale: true,
          axisLine: { lineStyle: { color: '#8392A5' } },
          splitLine: { show: true },
          splitArea: {show: true }
      },
      dataZoom: {
          type: 'slider',
          show: false,
          yAxisIndex: [0],
          left: '96%',
          bottom: '5%',
          start: 0,
          end: 100
      },
      series: seriesarr
    }
    myChart.setOption(option);
  }

  function initc2(data){
    var myChart = echarts.init(document.getElementById('c2'));
    var seriesarr = [];
    var legendarr = [];
    data.nameList.forEach(function(val,index,arr){
      legendarr.push(val.id+":"+val.name+"-盈利");
      legendarr.push(val.id+":"+val.name+"-亏损");
    });
    /**/
    data.stsm.forEach(function(val,index,arr){
      var seriestp = {
        type : 'bar',
        name : val.id+":"+val.name+"-盈利",
        data : val.tp,
        stack: val.id+":"+val.name,
      };

      var seriessl = {
        type: 'bar',
        name : val.id+":"+val.name+"-亏损",
        data : val.sl,
        stack: val.id+":"+val.name,
      };
      seriesarr.push(seriestp);
      seriesarr.push(seriessl);
    });
    var option = {
      title: {
        text: '盈亏比',
        textStyle: {
            fontSize: 12,
        },
        left: 0
      },
      legend: {
          data: legendarr
      },
      tooltip: {
          trigger: 'item',
          axisPointer: {
              type: 'cross'
          },
      },
      xAxis: {
          type: 'category',
          data: data.statLabel,
          axisLine: { lineStyle: { color: '#8392A5' } },
          splitLine: {show: true},
      },
      yAxis: {
          scale: true,
          axisLine: { lineStyle: { color: '#8392A5' } },
          splitLine: { show: true },
          splitArea: {show: true }
      },
      dataZoom: {
          type: 'slider',
          show: false,
          yAxisIndex: [0],
          left: '96%',
          bottom: '5%',
          start: 0,
          end: 100
      },
      series: seriesarr
    }
    myChart.setOption(option);
  }

  function initc3(data){
    var myChart = echarts.init(document.getElementById('c3'));
    var legendarr = [];
    data.nameList.forEach(function(val,index,arr){
      legendarr.push(val.id+":"+val.name+"-盈利");
      legendarr.push(val.id+":"+val.name+"-亏损");
    });
    var seriesarr = [];
    data.stsm.forEach(function(val,index,arr){
      var seriestp = {
        type : 'bar',
        name : val.id+":"+val.name+"-盈利",
        data : val.tpnum,
        stack: val.id+":"+val.name,
      };
      var seriessl = {
        type : 'bar',
        name : val.id+":"+val.name+"-亏损",
        data : val.slnum,
        stack: val.id+":"+val.name,
      };
      seriesarr.push(seriestp);
      seriesarr.push(seriessl);
    });
    var option = {
      title: {
        text: '加仓次数',
        textStyle: {
            fontSize: 12,
        },
        left: 0
      },
      legend: {
          data: legendarr
      },
      tooltip: {
          trigger: 'item',
          axisPointer: {
              type: 'cross'
          },
      },
      xAxis: {
          type: 'category',
          data: data.statLabel,
          axisLine: { lineStyle: { color: '#8392A5' } },
          splitLine: {show: true},
      },
      yAxis: {
          scale: true,
          axisLine: { lineStyle: { color: '#8392A5' } },
          splitLine: { show: true },
          splitArea: {show: true }
      },
      dataZoom: [{
          type: 'slider',
          show: false,
          yAxisIndex: [0],
          left: '96%',
          bottom: '5%',
          start: 0,
          end: 100
      }],
      series: seriesarr
    }
    myChart.setOption(option);
  }

  function initc4(data){
    var myChart = echarts.init(document.getElementById('c4'));
    var legendarr = [];
    data.nameList.forEach(function(val,index,arr){
      legendarr.push(val.id+":"+val.name+"-盈利总仓量");
      legendarr.push(val.id+":"+val.name+"-亏损总仓量");
    });
    var seriesarr = [];
    data.stsm.forEach(function(val,index,arr){
      var seriestp = {
        type : 'bar',
        name : val.id+":"+val.name+"-盈利总仓量",
        data : val.tpamount,
        stack: val.id+":"+val.name,
      };
      var seriessl = {
        type : 'bar',
        name : val.id+":"+val.name+"-亏损总仓量",
        data : val.slamount,
        stack: val.id+":"+val.name,
      };
      seriesarr.push(seriestp);
      seriesarr.push(seriessl);
    });
    var option = {
      title: {
        text: '总仓量',
        textStyle: {
            fontSize: 12,
        },
        left: 0
      },
      legend: {
          data: legendarr
      },
      tooltip: {
          trigger: 'item',
          axisPointer: {
              type: 'cross'
          },
      },
      xAxis: {
          type: 'category',
          data: data.statLabel,
          axisLine: { lineStyle: { color: '#8392A5' } },
          splitLine: {show: true},
      },
      yAxis: {
          scale: true,
          axisLine: { lineStyle: { color: '#8392A5' } },
          splitLine: { show: true },
          splitArea: {show: true }
      },
      dataZoom: [{
          type: 'slider',
          show: false,
          yAxisIndex: [0],
          left: '96%',
          bottom: '5%',
          start: 0,
          end: 100
      }],
      series: seriesarr
    }
    myChart.setOption(option);
  }

  function initc5(data){
    var myChart = echarts.init(document.getElementById('c5'));
    var legendarr = [];
    data.nameList.forEach(function(val,index,arr){
      legendarr.push(val.id+":"+val.name+"-盈利平均仓量");
      legendarr.push(val.id+":"+val.name+"-亏损平均仓量");
    });
    var seriesarr = [];
    data.stsm.forEach(function(val,index,arr){
      var seriestp = {
        type : 'bar',
        name : val.id+":"+val.name+"-盈利平均仓量",
        data : val.avgtpamount,
        stack: val.id+":"+val.name,
      };
      var seriessl = {
        type : 'bar',
        name : val.id+":"+val.name+"-亏损平均仓量",
        data : val.avgamount,
        stack: val.id+":"+val.name,
      };
      seriesarr.push(seriestp);
      seriesarr.push(seriessl);
    });
    var option = {
      title: {
        text: '平均仓量',
        textStyle: {
            fontSize: 12,
        },
        left: 0
      },
      legend: {
          data: legendarr
      },
      tooltip: {
          trigger: 'item',
          axisPointer: {
              type: 'cross'
          },
      },
      xAxis: {
          type: 'category',
          data: data.statLabel,
          axisLine: { lineStyle: { color: '#8392A5' } },
          splitLine: {show: true},
      },
      yAxis: {
          scale: true,
          axisLine: { lineStyle: { color: '#8392A5' } },
          splitLine: { show: true },
          splitArea: {show: true }
      },
      dataZoom: [{
          type: 'slider',
          show: false,
          yAxisIndex: [0],
          left: '96%',
          bottom: '5%',
          start: 0,
          end: 100
      }],
      series: seriesarr
    }
    myChart.setOption(option);
  }

  function initc6(data){
    var myChart = echarts.init(document.getElementById('c6'));
    var legendarr = [];
    data.nameList.forEach(function(val,index,arr){
      legendarr.push(val.id+":"+val.name+"-盈利总时间");
      legendarr.push(val.id+":"+val.name+"-亏损总时间");
    });
    var seriesarr = [];
    data.stsm.forEach(function(val,index,arr){
      var seriestp = {
        type : 'bar',
        name : val.id+":"+val.name+"-盈利总时间",
        data : val.tptime,
        stack: val.id+":"+val.name,
      };
      var seriessl = {
        type : 'bar',
        name : val.id+":"+val.name+"-亏损总时间",
        data : val.sltime,
        stack: val.id+":"+val.name,
      };
      seriesarr.push(seriestp);
      seriesarr.push(seriessl);
    });
    var option = {
      title: {
        text: '总时间(分钟)',
        textStyle: {
            fontSize: 12,
        },
        left: 0
      },
      legend: {
          data: legendarr
      },
      tooltip: {
          trigger: 'item',
          axisPointer: {
              type: 'cross'
          },
      },
      xAxis: {
          type: 'category',
          data: data.statLabel,
          axisLine: { lineStyle: { color: '#8392A5' } },
          splitLine: {show: true},
      },
      yAxis: {
          scale: true,
          axisLine: { lineStyle: { color: '#8392A5' } },
          splitLine: { show: true },
          splitArea: {show: true }
      },
      dataZoom: [{
          type: 'slider',
          show: false,
          yAxisIndex: [0],
          left: '96%',
          bottom: '5%',
          start: 0,
          end: 100
      }],
      series: seriesarr
    }
    myChart.setOption(option);
  }

  function initc7(data){
    var myChart = echarts.init(document.getElementById('c7'));
    var legendarr = [];
    data.nameList.forEach(function(val,index,arr){
      legendarr.push(val.id+":"+val.name+"-盈利平均时间");
      legendarr.push(val.id+":"+val.name+"-亏损平均时间");
    });
    var seriesarr = [];
    data.stsm.forEach(function(val,index,arr){
      var seriestp = {
        type : 'bar',
        name : val.id+":"+val.name+"-盈利平均时间",
        data : val.avgtptime,
        stack: val.id+":"+val.name,
      };
      var seriessl = {
        type : 'bar',
        name : val.id+":"+val.name+"-亏损平均时间",
        data : val.avgsltime,
        stack: val.id+":"+val.name,
      };
      seriesarr.push(seriestp);
      seriesarr.push(seriessl);
    });
    var option = {
      title: {
        text: '平均时间',
        textStyle: {
            fontSize: 12,
        },
        left: 0
      },
      legend: {
          data: legendarr
      },
      tooltip: {
          trigger: 'item',
          axisPointer: {
              type: 'cross'
          },
      },
      xAxis: {
          type: 'category',
          data: data.statLabel,
          axisLine: { lineStyle: { color: '#8392A5' } },
          splitLine: {show: true},
      },
      yAxis: {
          scale: true,
          axisLine: { lineStyle: { color: '#8392A5' } },
          splitLine: { show: true },
          splitArea: {show: true }
      },
      dataZoom: [{
          type: 'slider',
          show: false,
          yAxisIndex: [0],
          left: '96%',
          bottom: '5%',
          start: 0,
          end: 100
      }],
      series: seriesarr
    }
    myChart.setOption(option);
  }

  function initc8(data){
    var myChart = echarts.init(document.getElementById('c8'));
    var legendarr = [];
    data.nameList.forEach(function(val,index,arr){
      legendarr.push(val.id+":"+val.name+"-盈利总距离");
      legendarr.push(val.id+":"+val.name+"-亏损总距离");
    });
    var seriesarr = [];
    data.stsm.forEach(function(val,index,arr){
      var seriestp = {
        type : 'bar',
        name : val.id+":"+val.name+"-盈利总距离",
        data : val.tpdist,
        stack: val.id+":"+val.name,
      };
      var seriessl = {
        type : 'bar',
        name : val.id+":"+val.name+"-亏损总距离",
        data : val.sldist,
        stack: val.id+":"+val.name,
      };
      seriesarr.push(seriestp);
      seriesarr.push(seriessl);
    });
    var option = {
      title: {
        text: '总距离(点)',
        textStyle: {
            fontSize: 12,
        },
        left: 0
      },
      legend: {
          data: legendarr
      },
      tooltip: {
          trigger: 'item',
          axisPointer: {
              type: 'cross'
          },
      },
      xAxis: {
          type: 'category',
          data: data.statLabel,
          axisLine: { lineStyle: { color: '#8392A5' } },
          splitLine: {show: true},
      },
      yAxis: {
          scale: true,
          axisLine: { lineStyle: { color: '#8392A5' } },
          splitLine: { show: true },
          splitArea: {show: true }
      },
      dataZoom: [{
          type: 'slider',
          show: false,
          yAxisIndex: [0],
          left: '96%',
          bottom: '5%',
          start: 0,
          end: 100
      }],
      series: seriesarr
    }
    myChart.setOption(option);
  }

  function initc9(data){
    var myChart = echarts.init(document.getElementById('c9'));
    var legendarr = [];
    data.nameList.forEach(function(val,index,arr){
      legendarr.push(val.id+":"+val.name+"-盈利平均距离");
      legendarr.push(val.id+":"+val.name+"-亏损平均距离");
    });
    var seriesarr = [];
    data.stsm.forEach(function(val,index,arr){
      var seriestp = {
        type : 'bar',
        name : val.id+":"+val.name+"-盈利平均距离",
        data : val.avgtpdist,
        stack: val.id+":"+val.name,
      };
      var seriessl = {
        type : 'bar',
        name : val.id+":"+val.name+"-亏损平均距离",
        data : val.avgsldist,
        stack: val.id+":"+val.name,
      };
      seriesarr.push(seriestp);
      seriesarr.push(seriessl);
    });
    var option = {
      title: {
        text: '平均距离',
        textStyle: {
            fontSize: 12,
        },
        left: 0
      },
      legend: {
          data: legendarr
      },
      tooltip: {
          trigger: 'item',
          axisPointer: {
              type: 'cross'
          },
      },
      xAxis: {
          type: 'category',
          data: data.statLabel,
          axisLine: { lineStyle: { color: '#8392A5' } },
          splitLine: {show: true},
      },
      yAxis: {
          scale: true,
          axisLine: { lineStyle: { color: '#8392A5' } },
          splitLine: { show: true },
          splitArea: {show: true }
      },
      dataZoom: [{
          type: 'slider',
          show: false,
          yAxisIndex: [0],
          left: '96%',
          bottom: '5%',
          start: 0,
          end: 100
      }],
      series: seriesarr
    }
    myChart.setOption(option);
  }

  app.config(['$locationProvider', function ($locationProvider) {
    $locationProvider.html5Mode({
        enabled: true,
        requireBase: false
    });
  }]);
  app.controller('index', ['$scope', '$http','$location', '$filter','$window',function ($scope, $http,$location,$filter,$window) {
      //每个页面都要有的方法begin
      $scope.init = function(){
        $scope.wHeigth=$window.innerHeight;//获取屏幕的高度
        $scope.wWidth=$window.innerWidth;//获取屏幕的宽度
        var ids = $location.search().ids;
        if(ids=='' || ids==null || ids=='undefined'){
           $scope.haserror = true;
           $scope.errormessage = '参数不正确，请从货币组页面点击编辑按钮进入';
           return;
        }
        if(new String(ids).length>20){
           $scope.haserror = true;
           $scope.errormessage = '参数太长';
           return;
        }
        $scope.ids = ids;
        getUser($http,$scope,'策略收益比对','策略管理');
      }

      $scope.logout = function(){
        logout($http);
      }

      $scope.menuclick=function(menu){
        changemenuclass($scope,menu);
      }

      $scope.redi=function(url){
          location.href = url;
      }

      $scope.open=function(url){
          window.open(url);
      }
      //每个页面都要有的方法begin

      //每个页面都需要重写此方法，发生在init之后
      $scope.initAfter = function(){
        $scope.query();
      }

      $scope.query = function(){
        var url = 'quant4j-service/strategy_test/compare?ids='+$scope.ids;
        $scope.haserror = false;
        $http.get(url).success(function(data) {
            if(data.ok){
              $scope.data = data.data;
              initc1(data.data);
              initc2(data.data);
              initc3(data.data);
              initc4(data.data);
              initc5(data.data);
              initc6(data.data);
              initc7(data.data);
              initc8(data.data);
              initc9(data.data);
            }else{
              $scope.haserror = true;
              $scope.errormessage = data.message;
            }
        }).error(ajaxerror);
      }
      $scope.init();
  }]);
</script>
</html>